package com.ruoyi.environment.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.environment.domain.OpmEnvFacilityRecord;
import com.ruoyi.environment.service.IOpmEnvFacilityRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 环保维护Controller
 *
 * @author cjie
 * @date 2021-07-23
 */
@Api(tags = " 环保维护")
@RestController
@RequestMapping("/opmEnvFacilityRecord")
public class OpmEnvFacilityRecordController extends BaseController {
    @Autowired
    private IOpmEnvFacilityRecordService opmEnvFacilityRecordService;

    /**
     * 查询环保维护列表
     */
    @ApiOperation(value="查询环保维护列表", notes="查询环保维护列表")
    @PreAuthorize(hasPermi = "environment:opmEnvFacilityRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(OpmEnvFacilityRecord opmEnvFacilityRecord) {
        startPage();
        List<OpmEnvFacilityRecord> list = opmEnvFacilityRecordService.selectOpmEnvFacilityRecordList(opmEnvFacilityRecord);
        return getDataTable(list);
    }

    /**
     * 导出环保维护列表
     */
    @ApiOperation(value="导出环保维护列表", notes="导出环保维护列表")
    @PreAuthorize(hasPermi = "environment:opmEnvFacilityRecord:export")
    @Log(title = "环保维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OpmEnvFacilityRecord opmEnvFacilityRecord) throws IOException {
        List<OpmEnvFacilityRecord> list = opmEnvFacilityRecordService.selectOpmEnvFacilityRecordList(opmEnvFacilityRecord);
        ExcelUtil<OpmEnvFacilityRecord> util = new ExcelUtil<OpmEnvFacilityRecord>(OpmEnvFacilityRecord.class);
        util.exportExcel(response, list, "环保维护数据");
    }
    /**
     * 获取环保维护详细信息
     */
    @ApiOperation(value="获取环保维护详细信息", notes="获取环保维护详细信息")
    @PreAuthorize(hasPermi = "environment:opmEnvFacilityRecord:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(opmEnvFacilityRecordService.selectOpmEnvFacilityRecordById(id));
    }

    /**
     * 新增环保维护
     */
    @ApiOperation(value="新增环保维护", notes="新增环保维护")
    @PreAuthorize(hasPermi = "environment:opmEnvFacilityRecord:add")
    @Log(title = "环保维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OpmEnvFacilityRecord opmEnvFacilityRecord) {
        return toAjax(opmEnvFacilityRecordService.insertOpmEnvFacilityRecord(opmEnvFacilityRecord));
    }

    /**
     * 修改环保维护
     */
    @ApiOperation(value="修改环保维护", notes="修改环保维护")
    @PreAuthorize(hasPermi = "environment:opmEnvFacilityRecord:edit")
    @Log(title = "环保维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OpmEnvFacilityRecord opmEnvFacilityRecord) {
        return toAjax(opmEnvFacilityRecordService.updateOpmEnvFacilityRecord(opmEnvFacilityRecord));
    }

    /**
     * 删除环保维护
     */
    @ApiOperation(value="删除环保维护", notes="删除环保维护")
    @ApiImplicitParam(name = "ids", value = "环保维护ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "environment:opmEnvFacilityRecord:remove")
    @Log(title = "环保维护", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(opmEnvFacilityRecordService.deleteOpmEnvFacilityRecordByIds(ids));
    }
}
